package com.sskj.tibi.http;


import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.GetRequest;
import com.lzy.okgo.request.PostRequest;
import com.lzy.okgo.request.base.Request;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.lib.util.CommonUtil;
import com.sskj.tibi.bean.AddressBean;
import com.sskj.tibi.bean.OtherRecordBean;
import com.sskj.tibi.bean.RechargeBean;
import com.sskj.tibi.bean.RechargeRecordBean;
import com.sskj.tibi.bean.SearchTypeBean;
import com.sskj.tibi.bean.WithdrawBalanceBean;
import com.sskj.tibi.bean.WithdrawRechargeCoinBean;
import com.sskj.tibi.bean.WithdrawRecordBean;

import java.util.List;
import java.util.Map;

import okhttp3.Address;
import okhttp3.internal.http.HttpDate;

/**
 * 作者 :吕志豪
 * 简书：https://www.jianshu.com/u/6e525b929aac
 * github：https://github.com/lvzhihao100
 * 描述：
 * 创建时间：2018-10-15 14:08
 */
public class HttpService {


    /**
     * 充币
     *
     * @param code
     * @return
     */
    public PostRequest<HttpData<RechargeBean>> recharge(String code) {
        return OkGo.<HttpData<RechargeBean>>post(HttpConfig.BASE_URL + HttpConfig.RECHARGE)
                .params("wall_code", code)
                ;
    }

    /**
     * 充提币币种列表
     *
     * @return
     */
    public GetRequest<HttpData<List<WithdrawRechargeCoinBean>>> coinList() {
        return OkGo.<HttpData<List<WithdrawRechargeCoinBean>>>get(HttpConfig.BASE_URL + HttpConfig.COIN_LIST)
                ;
    }

    public GetRequest<HttpData<PageBean<RechargeRecordBean>>> getRechargeRecord(String page, String code) {
        return OkGo.<HttpData<PageBean<RechargeRecordBean>>>get(HttpConfig.BASE_URL + HttpConfig.RECHARGE_RECORD)
                .params("page", page)
                .params("code", code)
                ;
    }

    public PostRequest<HttpData> addAddress(String type, String address, String notes) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.ADD_ADDRESS)
                .params("type", type)
                .params("address", address)
                .params("notes", notes)
                ;
    }

    public GetRequest<HttpData<PageBean<WithdrawRecordBean>>> getWithdrawRecord(String page, String code) {
        return OkGo.<HttpData<PageBean<WithdrawRecordBean>>>get(HttpConfig.BASE_URL + HttpConfig.WITHDRAW_RECORD)
                .params("page", page)
                .params("code", code)
                ;
    }

    public GetRequest<HttpData<WithdrawBalanceBean>> getBalance(String code) {
        return OkGo.<HttpData<WithdrawBalanceBean>>get(HttpConfig.BASE_URL + HttpConfig.WITHDRAW_BALANCE)
                .params("wall_code", code)
                ;
    }

    public GetRequest<HttpData<Map<String, List<AddressBean>>>> getAddressList() {
        return OkGo.<HttpData<Map<String, List<AddressBean>>>>get(HttpConfig.BASE_URL + HttpConfig.ADDRESS_LIST)
                ;
    }

    public PostRequest<HttpData> withdraw(String address, String money,String wall_code, String payment_password, String google_code, String code) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.WITHDRAW)
                .params("address", address)
                .params("money", money)
                .params("wall_code", wall_code)
                .params("payment_password", CommonUtil.getFiveMd5Value(payment_password))
                .params("google_code", google_code)
                .params("code", code)
                ;
    }

    public GetRequest<HttpData<PageBean<OtherRecordBean>>> getOtherRecord(String page, String code, String type) {
        return OkGo.<HttpData<PageBean<OtherRecordBean>>>get(HttpConfig.BASE_URL + HttpConfig.OTHER_RECORD)
                .params("page", page)
                .params("type", type)
                .params("wallet_code", code)
                ;
    }

    public GetRequest<HttpData<SearchTypeBean>> getSearchType() {
        return OkGo.<HttpData<SearchTypeBean>>get(HttpConfig.BASE_URL + HttpConfig.SEARCH_TYPE);

    }

    public PostRequest<HttpData> deleteAddress(String id) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.DELETE_ADDRESS)
                .params("id", id)
                ;
    }
}
